﻿using RockBus.Composition.Interfaces;
using RockBus.Logging.Interfaces;
using RockBus.Monitoring.DataContracts;
using RockBus.Monitoring.Interfaces;
using RockBus.MonitoringService.Interfaces;
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace RockBus.Services
{
    [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single,
        InstanceContextMode = InstanceContextMode.PerCall)]
    public class MonitoringService : IMonitoringService
    {
        public static ILogger Logger = DependencyManager.Instance.Resolve<ILogger>();

        public static ICollectorManager CollectorManager = DependencyManager.Instance.Resolve<ICollectorManager>();

        public PerformanceCountersResponse GetCounters()
        {
            var snapshot = CollectorManager.GetSnapshot();
            if (snapshot == null)
            {
                return new PerformanceCountersResponse();
            }

            var response = new PerformanceCountersResponse(snapshot);
            return response;
        }
    }
}
